package com.fir.my.batis.plus.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fir.my.batis.plus.until.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
@DS("mysql2")
@Slf4j
public class YourRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<Map<String, Object>> findAll(String rq,String time) {
        String today = DateUtil.sd.format(DateUtil.getCutDay(0));
        System.out.println("today:" + today);
        String mdbSql = "SELECT  * FROM GPdata  where DATE >= '"+ rq +"'  ";
        if(today.equals(rq)){
            mdbSql = mdbSql + " and TIME > '" + time +"'";
        }
        mdbSql = mdbSql + " order by DATE desc ";
        log.info("执行sql:" + mdbSql);
        return jdbcTemplate.queryForList(mdbSql);
    }
}
